#!/bin/bash

# echo -e "\n\n=========== 修改静态ip ================"
# shellcheck disable=SC2012
enp=$(ls /etc/sysconfig/network-scripts/|egrep ifcfg |grep eth1.*|awk -F"-" '{print $2}')
enpway=/etc/sysconfig/network-scripts/ifcfg-$enp
sed -i '/BOOTPROTO/c BOOTPROTO=static' $enpway
sed -i '/ONBOOT/c ONBOOT=yes' $enpway
sed -i '/NM_CONTROLLED/c NM_CONTROLLED=yes' $enpway
cat >>/etc/sysconfig/network-scripts/ifcfg-$enp <<EOF
DNS1=$1
DNS2=$2
EOF
sudo systemctl restart NetworkManager